package com.scwang.smart.drawer.exercise.adapter

import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.scwang.smart.drawer.exercise.model.Example
import com.scwang.smart.drawer.exercise.model.Subject

class ExerciseAdapter(private val mExample: Example) : RecyclerView.Adapter<ExerciseHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ExerciseHolder {
        return if (viewType == 1) ExercisePagerGroup(parent, mExample) else ExercisePagerChoice(parent, mExample)
    }

    override fun onBindViewHolder(holder: ExerciseHolder, position: Int) {
        holder.onBind(mExample.subjects[position], position)
    }
    override fun getItemViewType(position: Int): Int {
        return if (mExample.subjects[position].GroupContent.isNullOrEmpty()) 0 else 1
    }

    override fun getItemCount(): Int {
        return mExample.Count
    }
}

